package com.yfp.goods.service.impl;

import com.yfp.goods.domain.Company;
import com.yfp.goods.mapper.CompanyMapper;
import com.yfp.goods.service.CompanyService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

import java.util.List;

/**
 * 公司表(Company)表服务实现类
 *
 *
 * @since 2024-01-07 13:28:57
 */
@Service("companyService")
public class CompanyServiceImpl implements CompanyService {
    @Resource
    private CompanyMapper companyMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param companyId 主键
     * @return 实例对象
     */
    @Override
    public Company queryById(String companyId) {
        return this.companyMapper.queryById(companyId);
    }

    /**
     * 分页查询
     *
     * @param company 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Company> queryByPage(Company company) {
        return this.companyMapper.queryAllByLimit(company);
    }

    /**
     * 新增数据
     *
     * @param company 实例对象
     * @return 实例对象
     */
    @Override
    public Company insert(Company company) {
        this.companyMapper.insert(company);
        return company;
    }

    /**
     * 修改数据
     *
     * @param company 实例对象
     * @return 实例对象
     */
    @Override
    public Company update(Company company) {
        this.companyMapper.update(company);
        return this.queryById(company.getCompanyId());
    }

    @Override
    public List<String> querySubsidiaryInformation(String companyId) {
        return this.companyMapper.querySubsidiaryInformation(companyId);
    }
}
